package testcase;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

import org.junit.Test;

import junit.framework.TestCase;
import dataobj.CourseTO;

public class TestCourseTO extends TestCase{
	
	private CourseTO to;
	
	@Override
	public void setUp(){
		to = new CourseTO();
	};
	
	@Override
	public void tearDown(){};
	
	@Test
	public void testName() {
		to.setName("abcd");
		assertEquals(to.getName(), "abcd");
	}
	
	@Test
	public void testCode() {
		to.setCode("efgh");
		assertEquals(to.getCode(), "efgh");
	}
	
	@Test
	public void testSession() {
		to.setSession("ijkl");
		assertEquals(to.getSession(), "ijkl");
	}
	
	@Test
	public void testCrn() {
		to.setCrn("mnop");
		assertEquals(to.getCrn(), "mnop");
	}
	
	@Test
	public void testVenue() {
		to.setVenue("qrst");
		assertEquals(to.getVenue(), "qrst");
	}
	
	@Test
	public void testInstructor() {
		to.setInstructor("uvwx");
		assertEquals(to.getInstructor(), "uvwx");
	}
	
	@Test
	public void testCredits() {
		Double credits = 3.0;
		to.setCredits(credits);
		assertEquals(to.getCredits(), credits);
	}
	
	@Test
	public void testStartTime() {
		Date temp = new Date();
		to.setStartTime(temp);
		assertEquals(to.getStartTime(), temp);
	}
	
	@Test
	public void testEndTime() {
		
		Date temp = new Date();
		to.setEndTime(temp);
		assertEquals(to.getEndTime(), temp);
	}
	
	@Test
	public void testStartDate() {
		Date temp = new Date();
		to.setStartDate(temp);
		assertEquals(to.getStartDate(), temp);
	}
	
	@Test
	public void testEndDate() {
		Date temp = new Date();
		to.setEndDate(temp);
		assertEquals(to.getEndDate(), temp);
	}
	
	@Test
	public void testWeekDay() {
		to.setWeekDay(5);
		assertEquals(to.getWeekDay(), 5);
	}
	
	@Test
	public void testToString() throws Exception{
		SimpleDateFormat tf = new SimpleDateFormat("MMM dd, yyyy hh:mm:ss a", Locale.US);
		tf.setTimeZone(TimeZone.getTimeZone("Asia/Hong_Kong"));
		
		CourseTO inputCourse = new CourseTO();
		inputCourse.setName("a");
		inputCourse.setCode("e");
		inputCourse.setSession("e");
		inputCourse.setCrn("e");
		inputCourse.setInstructor("e");
		inputCourse.setCredits(1.0);
		inputCourse.setVenue("abcd");
		inputCourse.setStartTime(tf.parse("NOV 25, 1980 12:25:00 am"));
		inputCourse.setEndTime(tf.parse("NOV 25, 1980 7:25:00 pm"));
		inputCourse.setStartDate(tf.parse("NOV 25, 1980 0:0:0 am"));
		inputCourse.setEndDate(tf.parse("NOV 25, 1980 11:59:59 pm"));
		inputCourse.setWeekDay(3);
		
		String output = "Code: e - e\nName: a\nInstructor: e\nVenue: abcd\nTime: 12:25 AM - 07:25 PM\nWeekday: Tuesday\n";
		assertEquals(output, inputCourse.toString());
	}
}
